package 力扣91;

/**
 * @ClassName : Day_14_100_相同的树
 * @Author : 骆发茂
 * @Date: 2021/12/25 11:29
 * @Description : https://leetcode-cn.com/problems/same-tree/
 */
public class Day_14_100_相同的树_递归 {
    /**
     * Definition for a binary tree node.
     * public class TreeNode {
     * int val;
     * TreeNode left;
     * TreeNode right;
     * TreeNode() {}
     * TreeNode(int val) { this.val = val; }
     * TreeNode(int val, TreeNode left, TreeNode right) {
     * this.val = val;
     * this.left = left;
     * this.right = right;
     * }
     * }
     */
    class Solution {
        public boolean isSameTree(TreeNode p, TreeNode q) {
            if (p == null && q == null) {
                return true;
            }
            if (p != null && q != null && p.val == q.val) {
                return isSameTree(p.right, q.right) && isSameTree(p.left, q.left);

            }
            return false;

        }
    }
}